{% extends "admin/base.html" %}
{% block title %}-添加评分{% endblock %}
{% block score %}current-item{% endblock %}
{% block mainbody %}
    <div class="main">
        <center>
            <h1>添加评分</h1>
            <span id="error" class="error">{{ error }}</span>
            <form id="user-form" method="post" action="/admin/score_add">
                <table class="table-adduser">
                    <tr>
                        <th>
                            <span>评测人:</span>
                        </th>
                        <td>
                            <input type="text" class="review_id" name="review_id" maxlength="11" placeholder="user_id">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>被评测人:</span>
                        </th>
                        <td>
                            <input type="text" class="be_review_id" name="be_review_id" maxlength="11" placeholder="user_id">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>评测日期:</span>
                        </th>
                        <td>
                            <input type="text" class="be_review_date" name="be_review_date" maxlength="7" placeholder="2018-01">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>工作任务:</span>
                        </th>
                        <td>
                            <input type="text" class="score_work" name="score_work" maxlength="2" placeholder="0-40">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>工作质量:</span>
                        </th>
                        <td>
                            <input type="text" class="score_quality" name="score_quality" maxlength="2" placeholder="0-30">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>工作技能:</span>
                        </th>
                        <td>
                            <input type="text" class="score_skill" name="score_skill" maxlength="2" placeholder="0-15">
                            <span class="error">*</span>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <span>工作态度:</span>
                        </th>
                        <td>
                            <input type="text" class="score_attitude" name="score_attitude" maxlength="2" placeholder="0-15">
                            <span class="error">*</span>
                        </td>
                    </tr>
                </table>
                <input type="button" id="submit_btn" value="提交">
            </form>

        </center>
    </div>

    <script src="/public/js/common/jquery-1.12.4.min.js"></script>
    <script>
        $(document).keydown(function(event) {
            if(event.keyCode == 13) {
                submitForm()
            }
        });

        $("#submit_btn").click(function() {
            submitForm()
        })

        function  submitForm() {
            if (checkForm()) {
                $("#error").html("正在提交...");
                $("#user-form").submit();
            }
        }

        function checkForm() {
            $("#error").html("");
            var flag = true
            $("input").each(function () {
                if(this.value.trim() == '') {
                    $("#error").html("未填写完整");
                    flag = false;
                }
            })
            return flag;
        }

        $("input").blur(function() {
            checkForm()
        })

    </script>
{% endblock %}
